<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>产看订单详情</title>
<style type="text/css">
    .l-table-edit {font-size: 12px;margin: auto; width:100%; border-collapse:collapse;}
 	.l-table-edit td{ padding:4px;border:1px solid #336699;}
</style>
</head>

	<table  class="l-table-edit">
		<tr>
			<td > 内容</td>
			<td >     </td>
			<td > 操作</td>
		</tr>
		<tr>
			<td width=33%>订单标识 </td>
			<td width=33%>  ${ orderD.id}   </td>
			<td width=33%> 
					<a onclick="sendLog('${ orderD.id}')" href="javascript:;">查看操作日志</a>
					<!--  { display: '查看操作日志', name: 'log',isSort : false, width: 100,
                	render: function (record, rowindex, value, column){
                		var html = '<a onclick="sendLog(\''+ record.id + '\')" href="javascript:;">查看操作日志</a>'; 
                		return html; 
                	}
                	
                }  -->
			
			
			</td>
		</tr>
		<tr>
			<td> 订单状态</td>
			<td> 
			<c:if test="${orderD.status=='01'}">待支付</c:if><c:if test="${orderD.status=='02'}">已支付</c:if><c:if test="${orderD.status=='03'}">已出票</c:if><c:if test="${orderD.status=='04'}">已完成</c:if><c:if test="${orderD.status=='05'}">已取消</c:if><c:if test="${orderD.status=='06'}">挂起</c:if>
			</td>
			<td> <p style="color: red;">请输入更改订单状态的原因：</p><br>
				<textarea rows="" cols="" style="width: 250px;height: 35px" id="reason"></textarea><br>
				
				<c:if test="${userId2==orderD.lock}">
					<c:choose>
								<c:when test="${orderD.status=='06'}">
									 <input  type="button" value="取消挂起,恢复之前状态" onclick="cancelStatus('${orderD.id}');"/>
								</c:when>
								<c:otherwise>
									<select name="modOrder" id="modOrder">
										<option value="">请选择</option>
										<option value="01">待支付</option>
										<option value="02">已支付</option>
										<option value="03">已成功</option>
										<option value="04">已完成</option>
										<option value="05">已取消</option>
										<option value="06">挂起</option>
									</select>
									 <input  type="button" value="更改订单状态" onclick="updateOrder('${orderD.id}')"/>
								</c:otherwise> 
					 </c:choose>
				 </c:if>
			</td>
		</tr>
		<tr>
			<td> 支付方式</td>
			<td> 
			            <c:if test="${orderD.payFrom=='01'}">线上支付</c:if> <c:if test="${orderD.payFrom=='02'}">到付</c:if>
			</td>
			<td> 
				
			</td>
		</tr>
		<tr>
			<td> 订单产品类型</td>
			<td>
				<c:if test="${orderD.type=='01'}">门票</c:if> <c:if test="${orderD.type=='02'}">酒店房间</c:if><c:if test="${orderD.type=='03'}">产品</c:if>
			</td>
			<td> 
			</td>
		</tr>
		<tr>
			<td> 下单用户名</td>
			<td>
				${orderD.memberObj.nickname }
			</td>
			<td> 
			</td>
			
		</tr>
		<tr>
			<td> 取票人姓名</td>
			<td>
				${orderD.contactor }
			</td>
			<td> 
			</td>
			
		</tr>
		<tr>
			<td> 手机号</td>
			<td>
				<a onclick="sendMsg('${orderD.id }','${orderD.phone}')" href="javascript:;">${orderD.phone}</a>
			</td>
			<td> 
			</td>
		</tr>
		<tr>
			<td> 邮寄地址：</td>
			<td>
				${orderD.proName}${orderD.cityName}${orderD.address}
			</td>
			<td> 
			</td>
		</tr>
		<tr>
			<td> 备注</td>
			<td>
				${orderD.memo}
			</td>
			<td> 
			</td>
		</tr>
		<tr>
			<td> 票号</td>
			<td>
				${orderD.stampNum}
			</td>
			<td> 
			</td>
		</tr>
		<tr>
			<td> 发票抬头</td>
			<td>
				${orderD.invoice}
			</td>
			<td> 
			</td>
		</tr>
		 <c:forEach items="${orderD.opList }" var="product">
						 
						 <tr>
							<td> <p style="color: red;">产品名称</p></td>
							<td>
								<a onclick="typeDetail('${product.pid}',${product.type })" href="javascript:;">${product.pname }</a>
							</td>
							<td> 
							</td>
						</tr>
						<tr>
							<td> <p>商家名称</p></td>
							<td>
								${product.companyName }
							</td>
							<td> 
							</td>
						</tr>
						<tr>
							<td> <p>商家联系方式</p></td>
							<td>
								${product.companyPhone }
							</td>
							<td> 
							</td>
						</tr>
						<tr>
							<td>下单价格</td>
							<td>
								${product.nprice}"
							</td>
							<td> 
							</td>
							
						</tr>
						<tr>
							<td>原始价格</td>
							<td>
								${product.mprice}
							</td>
							<td> 
							</td>
								
						</tr>
						<tr>
								<td> 数量</td>
								<td>
									${product.amount }
								</td>
								<td> 
							</td>
						</tr>
						
						<tr>
							<td>入住日期/游玩日期/下单日期</td>
							<td>
								${product.sdate }
							</td>
							<td> 
							</td>
						</tr>
						<tr>
							<td>结束日期/离开日期</td>
							<td>
								${product.ldate }
							</td>
							<td> 
							</td>
						</tr>
		</c:forEach>
	</table>
	
	
	<script type="text/javascript">
		
	function updateOrder(id){
		$.ligerDialog.confirm('你确定修改订单的状态吗？', 
				function (yes){
					if(yes){
						var status =$("#modOrder").find("option:selected").val();
						var reason =$("#reason").val();
						if(IsNull(reason)){
							alert("更改状态原因不能为空！");
						}else{
						//alert(status);
						$.post("/misc/order/updateOrder.htm",{id:id,status:status,reason:reason},
							function(data){
								
								var orderStatus=$("#modOrder").find("option:selected").text();
								alert("订单状态更改成功！");
								document.getElementById("orderStatus").value=orderStatus;
								parent.grid_ae.loadData();
							}
						); 
						}
					}
				})
	}
	
	function cancelStatus(id){
		$.ligerDialog.confirm('你确定取消挂起状态吗？', 
				function (yes){
					if(yes){
						var reason =$("#reason").val();
						if(IsNull(reason)){
							alert("更改状态原因不能为空！");
						}else{
						$.post("/misc/order/cancelOrderGQ.htm",{id:id,reason:reason},
								function(data){
									alert("取消挂起成功！");
									parent.grid_ae.loadData();
									parent.dialog_ae.close();
								}
							); 
						}
					}
				})
	}
	//查看状态操作日志
	function sendLog(id){
		var dialog_ae=null;
		dialog_ae = $.ligerDialog.open({ height: 700,width:800, url: "/misc/order/sendLogPage.htm?id="+id, showMax:true,isResize:true,isDrag:false,title:'查看日志'});
	}
	//发送短信
	function sendMsg(id,phone){
		var dialog_ae=null;
		dialog_ae = $.ligerDialog.open({ height: 300,width:900, url: "/misc/order/sendMsg.htm?id="+id+"&phone="+phone, showMax:true,isResize:true,isDrag:false,title:'发送短信'});
	}
	//查看产品详情
	function  typeDetail(pid,type){
		if(type=="01"){
			window.open ("/ticket.htm?id="+pid);
		}else if(type=="02"){
			window.open ("/hotel.htm?rid="+pid);
		}else if(type=="03"){
			window.open ("/product.htm?id="+pid);
		}
		
	}
	</script>
